<template>
  <div class="container">
    <!-- 面包屑导航 -->
    <breadcrumb :breadcrumbConfig=breadcrumbConfig></breadcrumb>
    <!--    <breadcrumb></breadcrumb>-->
    <!-- 面包屑导航 -->
    <div class="content">
      <h2>物流订单</h2>
      <h3>数据筛选</h3>
      <form-filed class="search-form" :formconfig="searchFormConfig.formconfig" :formData="searchFormConfig.formData" @cascaderValue="handlerCascaderValue"
                  @formDataval="dialogClick" ref="formAttr"></form-filed>
    </div>
    <div class="content">
      <h3>列表数据</h3>
      <div class="but-list">
        <div class="left">
          <el-button
              v-for="(val, key) in logisticsStatus" :key="key"
              :disabled="loading"
              :type="currentStatus === val.values ? 'primary' : 'info'" size="small" plain
              @click="onChangeLogisticsStatus(val.values)"
          >{{ val.title }}<span v-if="key === 'stayStockUp'|| key === 'stockUp'|| key === 'stayDeliverGoods'">（{{  val.total }}）</span>
          </el-button>
        </div>
        <div class="right">
          <el-button type="primary" size="small" class="stay-stock-up-but"
                     v-if="currentStatus === logisticsStatus.stayStockUp.values" @click="onStockUp (true)">批量备货
          </el-button>
          <el-button type="primary" size="small" class="stock-up-send-but"
                     v-if="currentStatus === logisticsStatus.stockUp.values" @click="deriveDeliverGoods()">导出发货
          </el-button>
          <el-button type="primary" size="small" class="stock-up-record-but"
                     v-if="currentStatus === logisticsStatus.stockUp.values" @click="onApplierExport()">导出记录
          </el-button>
          <el-button type="primary" size="small" class="stay-deliver-goods-but"
                     v-if="currentStatus === logisticsStatus.stayDeliverGoods.values" @click="importLogisticsData(3)">导出
          </el-button>
          <el-button type="primary" size="small" class="stay-deliver-goods-but"
                     v-if="currentStatus === logisticsStatus.stayDeliverGoods.values" @click="leadingIn()">导入物流单
          </el-button>
          <el-button size="small"  class="deliver-goods-but" v-if="currentStatus === logisticsStatus.deliverGoods.values"
                     @click="batchAmend">批量修改物流单号
          </el-button>
          <el-button size="small" type="primary" :loading="btnLoading"  v-if="currentStatus === logisticsStatus.deliverGoods.values"
                     @click="importLogisticsData(4)">导出物流数据
          </el-button>
          <el-button type="primary" size="small" class="stay-deliver-goods-but"
                     v-if="currentStatus === logisticsStatus.afterSale.values" @click="afterSaleLeadingIn()">批量导入换货单号
          </el-button>

        </div>
      </div>
      <lb-table
          v-horizontal-scroll='"always"'
		  v-loading="loadinglist"
          :column="columns"
          :data="page.list"
          pagination
          :total="page.totalNum"
          layout="total, sizes, prev, pager, next, jumper"
          :page-sizes="[5, 10, 20, 30, 50,200]"
          :current-page.sync="page.currentPage"
          :page-size="page.pageSize"
          @size-change="handleSizeChange"
          @p-current-change="handleCurrentChange"
          @selection-change="handleSelectionChange"
      >
      </lb-table>
    </div>
    <!--========================== el-dialog =================================-->
    <el-dialog
        :title="dialog.title"
        :visible.sync="dialog.visible"
        :width="dialog.width"
        :append-to-body="true"
    >
      <!-- 进度 -->
      <template v-if="dialog.type === 'shenheStep'">
        <step-progress :orderObj="dialog.row" :processFunc="dictionaries.process_func" type="shenheStep"></step-progress>
      </template>
      <!-- 修改物流单号 发货 -->
      <template v-if="dialog.type === 'modifyOrderNoOne'">
        <modify-order-no :orderObj="dialog.row" :type="dialog.type" source="service" ref="modifyOrderNo"
                         @submitState="modifyState"></modify-order-no>
      </template>
      <!-- 物流异常 -->
      <template v-if="dialog.type === 'wuliuAbnormal'">
        <div class="wuliuAbnormal_box">
          <div class="wuliuAbnormal_box_title">异常原因</div>
          <div class="radio_group">
            <el-radio-group v-model="wuliuStatus.resource">
              <el-radio class="radio_group_item" v-for="(item,index) in dictionaries.logistics_exception_reason"
                        :key="index" style="display:block" :label="item.dictId">{{ item.dictName }}
              </el-radio>
            </el-radio-group>
          </div>
        </div>
        <el-form label-width="65px" class="audit_textarea">

          <el-form-item label="备注">
            <el-input placeholder="请输入备注" maxlength="200" show-word-limit type="textarea"
                      v-model="wuliuStatus.remark"></el-input>
          </el-form-item>
        </el-form>
        <div class="dialogBtnright dialogBtnright_right" style="margin-top:20px">
          <el-button class="setPay_payment_btn_quxiao" @click="dialog.visible=false">取 消</el-button>
          <el-button class="setPay_payment_btn_queren" type="primary" @click="handlerAuditsubmit">确 定</el-button>
        </div>
      </template>
      <template v-if="dialog.type === 'logisticsMessageOne'">
        <step-progress :orderObj="dialog.row" type="logisticsMessageOne" source="service"></step-progress>
      </template>
      <template v-if="dialog.type === 'closeOrder'">
		<!-- {{dialog.row}} v-if="dialog.row.orderGenerateType == 1" -->
		<template v-if="dialog.row.orderGenerateType == 1">
			<el-radio-group v-model="setCloseOrder">
			  <el-radio v-for="(item,index) in dictionaries.order_main_close_reason" :key="index" class="setPay_payment"
			            :label="item.dictId">{{ item.dictName }}
			  </el-radio>
			</el-radio-group>
		</template>
		<template v-else>
			<p>第三方的自动订单不能关闭</p>
		</template>

        <div class="dialogBtnright dialogBtnright_right" style="margin-top:20px">
          <el-button class="setPay_payment_btn_quxiao" @click="dialog.visible=false">取 消</el-button>
          <el-button class="setPay_payment_btn_queren" type="primary" @click="handlerCloseOrderSubmit" v-if="dialog.row.orderGenerateType == 1">确 定</el-button>
        </div>
      </template>
      <template v-if="dialog.type === 'deriveRecord'">
        <lb-table
            :column="columnsDeriveRecord"
            :data="deriveRecordList.list"
            pagination
            :total="deriveRecordList.totalNum"
            layout="total, sizes, prev, pager, next, jumper"
            :page-sizes="[5, 10, 20, 30, 50]"
            :current-page.sync="page.currentPage"
            :page-size="page.pageSize"
            @size-change="handleSizeChangeDeriveRecord"
            @p-current-change="handleCurrentChangeDeriveRecord"
        >
        </lb-table>
      </template>
      <template v-if="dialog.type === 'deriveDeliverGoods'">
        <div style="text-align: center;margin:20px 0;font-size: 16px;">
          <p>是否导出共<span>{{ pageTotalNum }}</span>条{{titleName}}记录？</p>
        </div>
      </template>
      <div class="btnClass"
           v-if="dialog.type !== 'closeOrder'&&dialog.type !== 'logisticsMessage'&&dialog.type !== 'editWuliu'&&dialog.type !== 'modifyOrderNoOne'&&dialog.type !== 'logisticsMessageOne'&&dialog.type!='wuliuAbnormal'&&dialog.type != 'shenheStep'">
        <el-button type="primary" plain
                   @click="dialog.type=='deriveRecord'||dialog.type=='deriveDeliverGoods'?dialog.visible=false:closeDialog">
          取消
        </el-button>
        <el-button v-if="dialog.type !== 'deriveDeliverGoods'" type="primary"
                   @click="dialog.type=='deriveRecord'?dialog.visible=false:actionDialog">确认
        </el-button>
        <el-button v-if="dialog.type === 'deriveDeliverGoods'" type="primary" @click="deriveDownload">确认</el-button>
      </div>

      <div v-if="dialog.type === 'modifyOrderNoOne'" class="dialog-btn">
        <el-button class="setPay_payment_btn_quxiao" type="primary" plain @click="closeDialog">取消</el-button>
        <el-button class="setPay_payment_btn_queren" type="primary" @click="actionDialog">确认</el-button>
      </div>
    </el-dialog>
    <!--=========================== el-dialog end================================-->
    <!-- 导入物流单-->
    <el-dialog
        :title="dialoglogistics.title"
        :visible.sync="dialoglogistics.visible"
        :width="dialoglogistics.width"
        :append-to-body="true"
    >
      <template
          v-if="dialoglogistics.type=='importlogistics'||dialoglogistics.type=='batchAmend'||dialoglogistics.type=='afterSaleLeadingIn'"
          class="importlogistics">
        <div class="popIn">
          <el-upload
              ref="tops"
              class="upload-demo"
              accept=".doc,.docx,.xls,.xlsx,.csv"
              drag
              action="#"
              :multiple="false"
              :http-request="orderImport"
              :limit="1"
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          </el-upload>

        </div>
        <div class="dialog-footer">
          <div @click="downloadTemplate">
            <el-button type="text" icon="el-icon-download">导入模板下载</el-button>
          </div>
          <div>
            <el-button class="cancel" @click="dialoglogistics.visible=false; $refs['tops'].clearFiles();">取 消
            </el-button>
            <el-button class="affirm" type="primary" @click="templateMode(); $refs['tops'].clearFiles();">确 定
            </el-button>
          </div>
        </div>
      </template>
      <template
          v-if="dialoglogistics.type=='importlogisticslast'||dialoglogistics.type=='batchAmendlast'||dialoglogistics.type=='afterSaleLeadingInlast'"
          class="logisticsTable">
        <el-table
            :data="importLogisticsList.list"
            style="width: 100%"
            :header-cell-style="{ background: '#f8f8f8' }">
          <el-table-column
              prop="date"
              label="订单号"
              width="184"
          >
            <template slot="header" slot-scope="scope">
              <el-tooltip
                  class="item"
                  effect="dark"
                  placement="top"
              >
                <span style="color:red">*</span>
              </el-tooltip>
              订单号
            </template>
            <template slot-scope="scope">
              <el-input size="mini" v-model="scope.row.orderNo" placeholder="请输入内容"></el-input>
            </template>
          </el-table-column>

          <el-table-column
              prop="name"
              label="物流单号"
              width="184">
            <template slot="header">
              <el-tooltip
                  class="item"
                  effect="dark"
                  placement="top"
              >
                <span style="color:red">*</span>
              </el-tooltip>
              物流单号
            </template>
            <template slot-scope="scope">
              <el-input size="mini" v-model="scope.row.logisticsNumber" placeholder="请输入内容"></el-input>
            </template>
          </el-table-column>

          <el-table-column
              prop="address"
              label="物流公司"
              width="184">
            <template slot="header">
              <el-tooltip
                  class="item"
                  effect="dark"
                  placement="top"
              >
                <span style="color:red">*</span>
              </el-tooltip>
              物流公司
            </template>
            <template slot-scope="scope">
              <el-select v-model="scope.row.logisticsCompany" filterable clearable placeholder="请选择" size="mini">
                <el-option
                    v-for="item in dictionaries.courier_company"
                    :key="item.dictId"
                    :label="item.dictName"
                    :value="item.dictId">
                </el-option>
              </el-select>
            </template>
          </el-table-column>

          <el-table-column
              prop="address"
              label="出货仓库（选填）"
              width="184">
            <template slot-scope="scope">
              <el-select v-model="scope.row.commWarehouseId" clearable placeholder="请选择" size="mini">
                <el-option
                    v-for="item in commWarehouseList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column
              prop="address"
              label="失败理由">
            <template slot-scope="scope">
              {{ scope.row.failureReason }}
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination @size-change="handleSizeLogisticsTable"
                         @current-change="handleCurrentLogisticsTable"
                         :current-page="currentPage1"
                         :page-sizes="[10, 20, 50, 100, 200]"
                         :page-size="page.pageSize"
                         layout="total, sizes, prev, pager, next, jumper"
                         :total="importLogisticsList.totalNum"
                         prev-text="上一页"
                         next-text="下一页">
          </el-pagination>
        </div>
        <div class="dialogBtnright" style="margin-top:20px">
          <div>
            <el-button type="text" icon="el-icon-download" @click="downloadThisLocality">下载到本地</el-button>
          </div>
          <div>
            <el-button class="setPay_payment_btn_quxiao" @click="dialoglogistics.visible=false">取 消</el-button>
            <el-button class="setPay_payment_btn_queren" type="primary" @click="resubmit">重新提交</el-button>
          </div>

        </div>
      </template>

    </el-dialog>

    <!-- 物流单号导入 -->
  </div>

</template>

<script>
import formFiled from '@/components/form/index'
import breadcrumb from '@/components/breadcrumb'
import LbTable from '@/components/lb-table/lb-table'
import CloseOrder from './components/CloseOrder'
import StepProgress from '@/components/StepProgress'
import modifyOrderNo from './components/modifyOrderNo'

import mixinsCommon from './mixins/common.js'
import M from 'minimatch'
import { before } from 'xe-utils/methods'

export default {
  mixins: [mixinsCommon],
  components: {
    formFiled,
    breadcrumb,
    LbTable,
    CloseOrder,
    StepProgress,
    modifyOrderNo
  },
  data () {
    return {
	  loadinglist:false,
      btnLoading: false, // 导出物流数据加载
      titleName: '', //
      loading: false,
      sessionDictionaries: {}, // 缓存字典
      wuliuStatus: {
        resource: '',
        remark: ''
      },
      wuliuAbnormalId: '',
      currentPage1: 1,
      pageTotalNum: '', // 待备货商品的数量
      commWarehouseList: '', // 仓库数据
      importLogisticsList: [], // 导入物流单号失败的数据
      file: '', // 文件上传
      setCloseOrder: '', // 关闭原因选择值
      dialoglogistics: { visible: false, title: '编辑', type: '', row: {}, batch: false }, // 导入物流单号
      deriveRecordList: [], // 导出记录列表数据
      currentStatus: '',
      logisticsStatus: {
        all: { title: '全部', values: '', total: 0 }, // 全部
        stayStockUp: { title: '待备货', values: 1, total: 0 }, // 待备货
        stockUp: { title: '已备货', values: 2, total: 0 }, // 已备货
        stayDeliverGoods: { title: '待发货', values: 3, total: 0 }, // 待发货
        deliverGoods: { title: '已发货', values: 4, total: 0 }, // 已发货
        afterSale: { title: '售后件', values: 5, total: 0 } // 售后件
      },
      statusCount: { // 物流订单分页数量统计
        total: 100, // 全部数量
        preArrangeCount: 12, // 待备货数量
        arrangedCount: 12, // 已备货数量
        prePostCount: 12, // 待发货数量
        postedCount: 13, // 已发货数量
        afterSaleCount: 14 // 售后数量
      },
      multipleSelection: [],
      page: { list: [], pageNo: 1, pageSize: 10, totalNum: 0, currentPage: 1, status: '' },
      breadcrumbConfig: {
        list: [
          {
            title: '订单管理',
            type: '#ff0000',
            path: '/'
          },
          {
            title: '物流订单',
            type: '1',
            path: ''
          }
        ]
      },
      itemListSplice: [],
      itemListAll: [],
      orgCodevalue: '',
      searchFormVal: {},
      searchFormConfig: {
        formconfig: {
          labeWidth: 82, // 表单宽度
          itemList: [// 表单的list
            { type: 'input', prop: 'orderNo', placeholder: '请输入订单编号', label: '订单编号', size: 'small' },
            { type: 'input', prop: 'postUserInfo', placeholder: '请输入收货人信息', label: '收货人信息', size: 'small' },
            // {
            //   type: 'select', prop: 'status', placeholder: '请选择状态', label: '状态', size: 'small',
            //   option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            // },
            // {
            //   type: 'select', prop: 'payType', placeholder: '请选择支付方式', label: '支付方式', size: 'small',
            //   option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            // },
            {
              type: 'select', prop: 'platformId', placeholder: '请选择平台', label: '平台', size: 'small',
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            },
            // {
            //   type: 'select', prop: 'shopId', placeholder: '请选择店铺', label: '店铺', size: 'small',
            //   option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            // },
            {
              type: 'select', prop: 'applierId', placeholder: '请选择跟进客服', label: '跟进客服', size: 'small',
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            },
            {
              type: 'select', prop: 'logsticsExceptionReson', placeholder: '请选择物流状态', label: '物流异常', size: 'small',
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            },
            { type: 'input', prop: 'afterNo', placeholder: '请输入售后编号', label: '售后编号', size: 'small' },
            {
              type: 'select', prop: 'afterSaleStatus', placeholder: '请选择售后状态', label: '售后状态', size: 'small',
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            }, {
              type: 'select', prop: 'afterSalesType', placeholder: '请选择售后原因', label: '售后原因', size: 'small',
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            },
            { type: 'daterange', prop: 'postTime', placeholder: '请选择日期', label: '发货时间', size: 'small' },
            {
              type: 'cascader', prop: 'orgCode', placeholder: '请选择公司部门', label: '公司部门', size: 'small', showAllLevels: false,
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2跟进客服' }]
            },
            { type: 'input', prop: 'logisticsNumber', placeholder: '请输入物流单号', label: '物流单号', size: 'small' },
            { type: 'daterange', prop: 'createdTime', placeholder: '请选择日期', label: '提交时间', size: 'small' },
            {
              type: 'select', prop: 'orderGenerateType', placeholder: '请选择订单分类', label: '订单分类', size: 'small',
              option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
            },
			{
			  type: 'select', prop: 'orderType', placeholder: '请选择订单类型', label: '订单类型', size: 'small',
			  option: [{ label: '选择一', value: 'key1' }, { label: '选择二', value: 'key2' }]
			}
          ],
          btnarry: [// 表单按钮
            { name: '查询', click: 'add', type: 'primary', plain: true, size: 'small' },
            { name: '重置', click: 'clrear', type: 'primary', plain: true, size: 'small' }
          ]
        },
        formData: { // 表单提交数据，
          orderGenerateType: '',
          checkbox: []// 注：如果类型是checkbox，必须foemData里边提前声明数组
        }
      },
      activeName: 'goods',
      columnsDeriveRecord: [
        { label: '文件名', prop: 'fileName', minWidth: '230' },
        { label: '操作人', prop: 'userName', minWidth: '100' },
        { label: '导出时间', prop: 'createdDate', minWidth: '200' },
        {
          label: '操作', width: '100',
          render: (h, scope) => {
            return (
                <div>
                  <el-link type='primary' size='mini' onClick={() => {
                    this.downloadlink(scope.row.excelUrl)
                  }}>下载
                  </el-link>
                </div>
            )
          }
        }
      ],
      columns: [],
      // 公共  column
      columnCommon: [
        { type: 'selection' },
        {
          label: '订单编号', width: '220', align: 'left',
          render: (h, scope) => {
            return (

                <div >
                  <el-tooltip
                      class='item'
                      effect='dark'
                      content='单击复制'
                      placement='top'
                  >
                    <p onClick={() => { this.copyInfo(scope.row) }} style='cursor:pointer' >{scope.row.orderNo}</p>
                  </el-tooltip>

                  <p class={scope.row.platformOrderNo ? 'info' : 'hide-content info'}>关联订单：{scope.row.platformOrderNo}</p>
                </div>

            )
          }
        },
        {
          label: '收货人', align: 'left', minWidth: '140',
          render: (h, scope) => {
            return (
                <div>
                  <p>{scope.row.postName ? scope.row.postName : '-'}</p>
                  <p>{scope.row.postContact ? scope.row.postContact : '-'}</p>

                </div>
            )
          }
        },
        {
          label: '收货地址', align: 'left', minWidth: '250',
          render: (h, scope) => {
            return (
                <div>
                  <p>{scope.row.postAddress ? scope.row.postAddress : '-'}</p>
                </div>
            )
          }
        },
        {
          label: '商品名称', align: 'left', minWidth: '250',
          render: (h, scope) => {
            return (
                <div>
                  <p title={scope.row.goodsName}>{scope.row.goodsName}</p>
                </div>
            )
          }
        },
        { label: '数量', prop: 'quantity' },
        { label: '公司部门', prop: 'orgName', minWidth: '180', align: 'left' },
        { label: '订单分类', prop: 'orderGenerateTypeLabel', minWidth: '180', align: 'left' },
        { label: '跟进客服', prop: 'applierName', minWidth: '150', align: 'left' }
      ],
      // 全部  column
      columnAll: [
        // { label: '支付方式', prop: 'payTypeLabel', width: '170', align: 'left' },
        {
          label: '金额', align: 'left', minWidth: '150',
          render: (h, scope) => {
            return (
                <div>
                  <p>总价:￥{scope.row.totalAmount ? scope.row.totalAmount : '0'}</p>
                  <p>已收:￥{scope.row.receivedAmount ? scope.row.receivedAmount : '0'}</p>
                  <p>代收:￥{scope.row.collectionAmount ? scope.row.collectionAmount : '0'}</p>
                </div>
            )
          }
        },
        {
          label: '备注/留言', align: 'left', minWidth: '250',
          render: (h, scope) => {
            return (
                <div>
                  <p>客户留言:{scope.row.userRemarks ? scope.row.userRemarks : '-'}</p>
                  <p>客服备注:{scope.row.remarks ? scope.row.remarks : '-'}</p>
                </div>
            )
          }
        },
        {
          label: '状态', align: 'left',
          render: (h, scope) => {
            return (
                <div>
                  <p class={scope.row.status === 1 ? 'danger' : 'hide-content' ||
                  scope.row.status === 2 ? 'warning' : 'hide-content' ||
                  scope.row.status === 3 ? 'primary' : 'hide-content' ||
                  scope.row.status === 4 ? 'success' : 'hide-content' ||
                  scope.row.status === 5 ? 'info' : 'hide-content'}>{scope.row.statusLabel ? scope.row.statusLabel : '-'}</p>
                </div>
            )
          }
        },
        { label: '提交时间', prop: 'submitDate', width: '180', align: 'left' },
        {
          label: '操作', width: '140', fixed: 'right',
          render: (h, scope) => {
            return (
                <div>
                  <el-link type='primary' size='mini' onClick={() => {
                    this.toOtherPages('orderDetails', scope.row, 'logistics')
                  }}>查看
                  </el-link>
                  <el-link type='primary' size='mini' onClick={() => { this.showDialog('审核流程', '640px', 'shenheStep', scope.row, scope.$index) }}>进度</el-link>

                </div>
            )
          }
        }
      ],
      // 待备货 column + 已备货 column +  待发货 column + 已发货 column
      columnMiddle: [
        // { label: '支付方式', prop: 'payTypeLabel', minWidth: '150', align: 'left' },
        {
          label: '金额', align: 'left', minWidth: '160',
          render: (h, scope) => {
            return (
                <div>
                  <p>总价:￥{scope.row.totalAmount ? scope.row.totalAmount : '0'}</p>
                  <p>已收:￥{scope.row.receivedAmount ? scope.row.receivedAmount : '0'}</p>
                  <p>代收:￥{scope.row.collectionAmount ? scope.row.collectionAmount : '0'}</p>
                </div>
            )
          }
        },
        {
          label: '备注/留言', minWidth: '250', align: 'left',
          render: (h, scope) => {
            return (
                <div>
                  <p>客户留言:{scope.row.userRemarks ? scope.row.userRemarks : '-'}</p>
                  <p>客服备注:{scope.row.remarks ? scope.row.remarks : '-'}</p>
                </div>
            )
          }
        },
        { label: '提交时间', prop: 'submitDate', minWidth: '180', align: 'left' }
      ],
      // 售后件 column
      columnAfterSale: [
        {
          label: '金额', align: 'left', minWidth: '150',
          render: (h, scope) => {
            return (
                <div>
                  <p>总价:￥{scope.row.totalAmount ? scope.row.totalAmount : '0'}</p>
                  <p>已收:￥{scope.row.receivedAmount ? scope.row.receivedAmount : '0'}</p>
                  <p>代收:￥{scope.row.collectionAmount ? scope.row.collectionAmount : '0'}</p>
                </div>
            )
          }
        },
        { label: '收货状态', minWidth: '120', prop: 'afterSaleType', align: 'left' },
        {
          label: '操作', minWidth: '180', fixed: 'right',
          render: (h, scope) => {
            return (
                <div>
                  <el-link type='primary' size='mini' onClick={() => {
                    this.toOtherPages('afterSaleRecordList', scope.row, 'afterSaleRecordList')
                  }}>售后记录
                  </el-link>
                </div>
            )
          }
        }
      ]
    }
  },
  watch: {
    platformDataList (val, oldVal) { // 平台
      val.forEach(item => {
        item.label = item.name
        item.value = item.id
      })
      const index = this.searchFormConfig.formconfig.itemList.findIndex(e => {
        return e.label === '平台'
      })
      this.searchFormConfig.formconfig.itemList[index].option = val
    },
    orgCodeList (val, oldVal) {
      val.forEach(item => {
        item.label = item.reallyName
        item.value = item.id
      })
      const index = this.searchFormConfig.formconfig.itemList.findIndex(e => { return e.label === '公司部门' })
      this.searchFormConfig.formconfig.itemList[index].option = val
    },
    /*
    shopDataList (val, oldVal) { // 店铺
      console.log(val)
      val.forEach(item => {
        item.label = item.name
        item.value = item.id
      })
      const index = this.searchFormConfig.formconfig.itemList.findIndex(e => {
        return e.label === '店铺'
      })
      this.searchFormConfig.formconfig.itemList[index].option = val
    },
    */
    salesAuthority (val, oldVal) { // 跟进客服
      val.forEach(item => {
        item.label = item.reallyName
        item.value = item.id
      })
      const index = this.searchFormConfig.formconfig.itemList.findIndex(e => {
        return e.label === '跟进客服'
      })
      this.searchFormConfig.formconfig.itemList[index].option = val
    },
    dictionaries: {
      handler (newVal, oldVal) {
        setTimeout(_ => {
          // this.setSearchDictionaries('状态', 'order_main_subset_status')
          // this.setSearchDictionaries('支付方式', 'order_pay_type')
          this.setSearchDictionaries('物流异常', 'logistics_exception_reason')
          this.setSearchDictionaries('订单分类', 'order_generate_type')
		  this.setSearchDictionaries('订单类型', 'order_main_type')
          // 售后件
          if (this.currentStatus === this.logisticsStatus.afterSale.values) {
            this.setSearchDictionaries('售后状态', 'after_sale_status')
            this.setSearchDictionaries('售后原因', 'after_sale_reason')
          }
        }, 100)
      },
      deep: true // 为true，表示深度监听
    }
  },
  created () {
    // console.log(location.protocol)
    this.initSearchList() // 初始化，搜索需要的列表数据
    // 初始表格
    this.columns = this.columnCommon.concat(this.columnAll)
    this.itemListAll = [...this.searchFormConfig.formconfig.itemList]
    const tempItemList = this.searchFormConfig.formconfig.itemList
    tempItemList.splice(5, 3)
    this.itemListSplice = [...tempItemList]
  },
  mounted () {
    this.$nextTick(() => {
      setTimeout(_ => {
        // 获取本地缓存字典
        const sessionDictionaries = JSON.parse(sessionStorage.getItem('dictionaries'))
        if (sessionDictionaries) {
          this.sessionDictionaries = sessionDictionaries
        }
        this.fetchData('init')
      }, 1000)
    })
  },
  methods: {
    handlerCascaderValue (value) {
      console.log(value, 'value')
      this.orgCodevalue = value
    },
    // 导出物流数据
    importLogisticsData (typeStatus) {
      if (!this.searchFormConfig.formData.orgCode || this.searchFormConfig.formData.orgCode.length === 0) {
        return this.$message.warning('请选择部门！')
      }
      this.btnLoading = true
      // this.dialogClick()
      // console.log(this.$refs.formAttr.submitForm)
      this.$refs.formAttr.submitForm('ruleForm')
      console.log(this.searchFormVal)
      const ids = []
      if (this.multipleSelection.length != 0) {
        this.multipleSelection.forEach((item) => {
          ids.push(item.orderId)
        })
      }
      let data = {
        orderIdList: ids,
        status: typeStatus,
        pageNo: this.page.pageNo,
        pageSize: this.page.pageSize
      }
      const searchForm = this.searchFormVal
      data = Object.assign(data, searchForm)
      if (data.orgCode) {
        data.orgCode = searchForm.orgCode[searchForm.orgCode.length - 1]
      }
      if (data.postTime) {
        data.postTimeStart = data.postTime[0]
        data.postTimeEnd = data.postTime[1]
      }
      if (data.createdTime) {
        data.createdTimeStart = data.createdTime[0]
        data.createdTimeEnd = data.createdTime[1]
      }

      console.log(searchForm)
      if (!data.postTimeEnd || !data.postTimeStart) {
        if (typeStatus !== 3) {
          this.btnLoading = false
          return this.$message.warning('请选择时间！')
        }
      }
      // if (!data.orgCode) {
      //   return this.$message.warning('请选择公司部门！')
      // }
      this.$api.logisticsExport(data).then((res) => {
        if (res.code == 0) {
          res.data.forEach(item => {
            this.downloadlink(item)
          })
          this.btnLoading = false
          // this.downloadlink(res.data)
          this.$message.success('操作成功！')
          this.dialog.visible = false
          this.fetchData('search')
        } else {
          this.btnLoading = false
        }
      }).catch((err) => {
        console.log(err)
        this.btnLoading = false
      })
    },
    // 复制
    copyInfo (row) {
      console.log(row, 'row')
      const that = this
      // let inline = this.line.find((res) => res.id == row.userDitch);
      const info =
          (row.orderNo == null ? '无' : row.orderNo)
      that.$copyText(info).then(
          function (e) {
            that.$message({
              type: 'success',
              message: '复制成功'
            })
          },
          function (e) {
            that.$message({
              type: 'warning',
              message: '复制失败'
            })
          }
      )
    },
    // 物流异常弹框
    wuliuAbnormal (row) {
      // console.log(row, 'row')
      this.wuliuStatus.resource = ''
      this.wuliuStatus.remark = ''
      this.dialog.visible = true
      this.dialog.title = '物流异常'
      this.dialog.width = '640px'
      this.dialog.type = 'wuliuAbnormal'
      this.wuliuAbnormalId = row.orderNo
    },
    // 物流异常弹框确定提交
    handlerAuditsubmit () {
      if (this.wuliuStatus.resource == '') {
        this.$message.warning('请选择异常原因！')
        return
      }
      const data = {
        orderNo: this.wuliuAbnormalId,
        logsticsExceptionReson: this.wuliuStatus.resource,
        exceptinRemeark: this.wuliuStatus.remark
      }
      this.$api.updateOrderMainLogisticsException(data).then(res => {
        if (res.code == 0) {
          this.$message.success('操作成功')
          this.dialog.visible = false
          this.fetchData('search')
        }
      })
    },

    // 下载到本地
    downloadThisLocality () {
      this.$api.afterDownloadExportError(this.importLogisticsList.list).then(res => {
        if (res.code == 0) {
          this.downloadlink(res.data)
          this.fetchData()
        }
      })
    },
    // 重新提交
    resubmit () {
      // console.log(this.dialoglogistics.type)
      let required
      if (this.dialoglogistics.type == 'afterSaleLeadingInlast') {
        required = this.$api.afterReImportLogistics
      } else {
        required = this.$api.reImportLogistics
      }
      // console.log(this.importLogisticsList)
      required(this.importLogisticsList.list).then(res => {
        if (res.code === 0) {
          this.dialoglogistics.visible = false // 关闭弹窗
          // this.importLogisticsList = res.data
          this.$message.success('操作成功')
          this.fetchData('search')
        } else if (res.code === 104) {
          // console.log(res)
          this.importLogisticsList = res.data
          // this.$message.warning('提交失败！')
          this.fetchData()
        } else {
          console.log(this.importLogisticsList, 'this.importLogisticsList')
        }
      }).catch((err) => {
        console.log(err)
        // this.loading = false
      })
    },
    // 修改售后物流单号，提交状态
    modifyState (state) {
      // console.log('修改售后物流单号，提交状态', state)
      this.fetchData('search')
      // 提交后，关闭并还原值
      this.closeDialog()
    },
    // 关闭订单确定
    handlerCloseOrderSubmit () {
      if (this.setCloseOrder) {
        const data = {
          id: this.dialog.row.orderId,
          closeReason: this.setCloseOrder
        }
        this.$api.wuliuCloseOrder(data).then(res => {
          if (res.code == 0) {
            this.$message.success('操作成功')
            this.dialog.visible = false
            this.fetchData('search')
          }
        })
      } else {
        this.$message.warning('请选择关闭订单原因！')
      }
    },

    // 导入物流单号模板下载
    downloadTemplate () {
      const exportModelUrl = this.sessionDictionaries.export_model_url
      let modelIndex
      // console.log(this.currentStatus, this.logisticsStatus.stayDeliverGoods.values)
      if (this.currentStatus === this.logisticsStatus.deliverGoods.values || this.currentStatus === this.logisticsStatus.stayDeliverGoods.values) {
        modelIndex = exportModelUrl.findIndex(item => { return item.dictId === 'logistics_number_import_success' }) // 待发货
      } else {
        modelIndex = exportModelUrl.findIndex(item => { return item.dictId === 'after_number_import_success' }) // 售后件
      }
      // this.downloadlink('https://5eck-down.oss-cn-shenzhen.aliyuncs.com/model/五域v1.2.2导入导出文件模板/%E5%AF%BC%E5%85%A5%E7%89%A9%E6%B5%81%E5%8D%95%20-%20%E6%88%90%E5%8A%9F.xls?versionId=CAEQJxiBgMDOsa_kgxgiIDEwNTJhMTVmZTgyYTQ1MzE4NmRjYmQ0ZjFjZTk4MDg2')
      this.downloadlink(exportModelUrl[modelIndex].dictName)
    },
    // 导入物流单
    orderImport (fileObj) {
      this.file = fileObj.file
    },
    // 导入数据请求
    // 一键导入
    templateMode () {
      this.$refs.tops.clearFiles()
      const formData = new FormData()
      formData.append('file', this.file)
      // console.log(this.file, 'this.file')
      if (this.file == '') {
        return this.$message.warning('请上传文件！')
      }
      let required
      if (this.dialoglogistics.type == 'afterSaleLeadingIn') { // 售后件
        required = this.$api.afterImportLogistics
      } else {
        required = this.$api.importLogistics
      }
      required(formData).then(res => {
        // console.log(res)
        if (res.code == 0) {
          this.$message.success('导入成功！')
          this.dialoglogistics.visible = false
          this.downloadlink(res.data)
          this.fetchData('search')
        } else if (res.code == 104) {
          // this.$message.warning('导入失败！')
          this.importLogisticsList = res.data
          // this.dialoglogistics.visible = false
          if (this.dialoglogistics.type == 'afterSaleLeadingIn') {
            this.dialoglogistics.type = 'afterSaleLeadingInlast'
          }
          if (this.dialoglogistics.type == 'batchAmend') {
            this.dialoglogistics.type = 'batchAmendlast'
          }
          if (this.dialoglogistics.type == 'importlogistics') {
            this.dialoglogistics.type = 'importlogisticslast'
          }
          this.dialoglogistics.title = '导入物流单号失败'
          this.dialoglogistics.width = '1062px'
          this.dialoglogistics.visible = true
        } else {
          console.log('err')
        }
        this.getCommWarehouse()
      }).catch(err => {
        console.log(err)
      })
    },
    // 仓库列表
    getCommWarehouse () {
      const params = { pageNo: 1, pageSize: 10000 }
      this.$api.commWarehouse(params).then((res) => {
        this.commWarehouseList = res.data.list
      }).catch((err) => {
        console.log(err)
      })
    },
    // 批量修改物流单号
    batchAmend () {
      this.dialoglogistics.visible = true
      this.dialoglogistics.title = '批量修改物流单号'
      this.dialoglogistics.width = '640px'
      this.dialoglogistics.type = 'batchAmend'
    },
    // 导入物流单号
    leadingIn () {
      this.dialoglogistics.visible = true
      this.dialoglogistics.title = '导入物流单号'
      this.dialoglogistics.width = '640px'
      this.dialoglogistics.type = 'importlogistics'
    },
    // 售后件导入物流单
    afterSaleLeadingIn () {
      this.dialoglogistics.visible = true
      this.dialoglogistics.title = '导入物流单号'
      this.dialoglogistics.width = '640px'
      this.dialoglogistics.type = 'afterSaleLeadingIn'
    },
    // 导出发货确定按钮
    deriveDownload () {
      const ids = []
      if (this.multipleSelection.length != 0) {
        this.multipleSelection.forEach((item) => {
          ids.push(item.orderId)
        })
      }
      if (this.orgCodevalue) {
        this.orgCodevalue = typeof (this.orgCodevalue) === 'string' ? this.orgCodevalue : this.orgCodevalue[this.orgCodevalue.length - 1]
      }
      const data = {
        orderIdList: ids,
        status: 2,
        orgCode: this.orgCodevalue
      }
	  if(this.searchFormVal.orderGenerateType){
	  	data.orderGenerateType = this.searchFormVal.orderGenerateType;
	  }
      //return console.log(data,this.searchFormVal)
      this.$api.logisticsExport(data).then((res) => {
        if (res.code == 0) {
          res.data.forEach(item => {
            this.downloadlink(item)
          })
          // this.downloadlink(res.data)
          this.$message.success('操作成功！')
          this.dialog.visible = false
          this.fetchData('search')
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 导出发货
    deriveDeliverGoods () {
      if (!this.searchFormConfig.formData.orgCode || this.searchFormConfig.formData.orgCode.length === 0) {
        return this.$message.warning('请选择部门！')
      }
      if (this.multipleSelection.length != 0) {
        this.pageTotalNum = this.multipleSelection.length
      } else {
        this.pageTotalNum = this.page.totalNum
      }
      this.dialog.visible = true
      this.dialog.title = '导出发货'
      this.dialog.width = '540px'
      this.dialog.type = 'deriveDeliverGoods'
      this.titleName = '已备货'
    },
    // 操作 - 关闭订单后
    closeOrderData (state) {
      // 提交后，关闭并还原值
      this.closeDialog()
    },
    // 初始化，搜索需要的列表数据
    initSearchList () {
      const params = { pageNo: 1, pageSize: 1001 }
      this.getSalesAuthority(params) // 跟进客服
      this.getPlatformDataList(params) // 平台
      this.getShopDataList(params) // 店铺
      this.getOrgTreeList() // 公司部门
    },
    // 接受表单组件的数据
    dialogClick (val, state) {
      this.searchFormVal = val
      console.log(this.searchFormVal, 'searchFormVal')
      this.fetchData('search')
      // this.formFiledData = Object.assign(this.formFiledData, val)
      // console.log(this.formFiledData,'接受表单组件的数据');
    },
    // 公司部门
    getOrgTreeList (params) {
      // orgProcessOrgList
      const paramsVersion = { 'request': { 'orgName': '', 'orgType': '' }, 'version': '' }
      this.$api.orgTreeList(paramsVersion).then((res) => {
        this.orgCodeList = res.data

        // id 为 1 的超级管理员不做默认
        const userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
        if (userInfo && userInfo.id !== 1) {
          if (res.data[0].children) {
            // const orgCode = JSON.parse(sessionStorage.getItem('orgCode'))
            if (this.searchForm && this.searchForm.orgCode) {
              this.searchForm.orgCode = [...userInfo.orgCodes]
            }
          } else {
            this.searchForm.orgCode.push(userInfo.orgCode)
          }
          if (this.isFirst > 2) {
            this.fetchData('search')
          }
        }
        this.isFirst++
      }).catch((err) => {
        console.log(err)
      })
    },
    fetchData (type) {
      this.loadinglist = true
      if (type === 'reset') {
        this.$refs['searchForm'].resetFields()
        this.page.pageNo = 1
        this.page.pageSize = 10
        this.page.currentPage = 1
      }
      let params = {
        pageNo: this.page.pageNo,
        pageSize: this.page.pageSize,
        status: this.page.status
      }
      if (type === 'init') {
        let userInfo = sessionStorage.getItem('userInfo')
        if (userInfo) {
          userInfo = JSON.parse(userInfo)
        }
        if (userInfo.orgCode === 'DT574796048' || userInfo.orgCode === 'DT574801057' || userInfo.orgCode === 'DT575225021') {
          const orderGenerateType = '1'
          this.searchFormConfig.formData.orderGenerateType = orderGenerateType
          params['orderGenerateType'] = orderGenerateType
        }
      }
	  if(type === 'status'){
		  params['orderGenerateType'] = this.searchFormConfig.formData.orderGenerateType
	  }
      const searchForm = this.searchFormVal
      params = Object.assign(params, searchForm)
      if (params.orgCode) {
        params.orgCode = searchForm.orgCode[searchForm.orgCode.length - 1]
      }

      if (type === 'search') {
        this.page.currentPage = 1
        this.page.pageNo = 1
        params.pageNo = 1
        const searchForm = this.searchFormVal
        params.pageNo = this.page.pageNo
        params = Object.assign(params, searchForm)
        if (params.postTime) {
          params.postTimeStart = params.postTime[0]
          params.postTimeEnd = params.postTime[1]
        }
        if (params.createdTime) {
          params.createdTimeStart = params.createdTime[0]
          params.createdTimeEnd = params.createdTime[1]
        }

        if (params.orgCode) {
          params.orgCode = params.orgCode[params.orgCode.length - 1]
        }
        // params.categoryId = searchForm.categoryId[searchForm.categoryId.length - 1]
        // 去除字符串 前后 空格
        for (const item in params) {
          if (typeof params[item] === 'string') {
            params[item] = params[item].trim()
          }
        }
      }
      let pageListFun
      if (params.status === 5) {
        pageListFun = this.$api.afterPageList
      } else {
        pageListFun = this.$api.logisticsPageList
      }
      pageListFun(params).then((res) => {
        if (res.code === 0) {
          this.page.list = res.data.list
          this.page.totalNum = res.data.totalNum
        } else {
          console.log('goodsPageList - 失败', type)
        }
        this.loadinglist = false
        this.getStatusCount(params)// 物流订单分页数量统计查询接口
      }).catch((err) => {
        console.log(err)
        this.loadinglist = false
      })
    },
    // 物流订单分页数量统计查询接口
    getStatusCount (params) {
      // const params = {}
      params = {}
      this.$api.logisticsGetStatusCount(params).then((res) => {
        this.statusCount = res.data
        this.logisticsStatus.all.total = res.data.total // 全部
        this.logisticsStatus.stayStockUp.total = res.data.preArrangeCount // 已备货
        this.logisticsStatus.stockUp.total = res.data.arrangedCount // 已备货
        this.logisticsStatus.stayDeliverGoods.total = res.data.prePostCount // 待发货
        this.logisticsStatus.deliverGoods.total = res.data.postedCount // 已发货
        this.logisticsStatus.afterSale.total = res.data.afterSaleCount // 售后件
      }).catch((err) => {
        console.log(err)
      })
    },
    handleCurrentChange (currentChange) {
      this.page.pageNo = currentChange
      this.fetchData()
      console.log(currentChange)
    },
    handleSizeChange (sizeChange) {
      this.page.currentPage = 1
      this.page.pageSize = sizeChange
      this.fetchData()
    },
    handleSelectionChange (val) {
      this.multipleSelection = val
    },
    // 每页条数
    handleSizeChangeDeriveRecord (val) {
      this.page.currentPage = 1
      this.page.pageSize = val
      this.onApplierExport()
    },
    // 当前页
    handleCurrentChangeDeriveRecord (val) {
      this.page.pageNo = val
      this.onApplierExport()
    },
    // 每页条数
    handleSizeLogisticsTable () {

    },
    // 当前页
    handleCurrentLogisticsTable () {

    },
    // 备货
    onStockUp (batch, obj) {
      // true 批量
      const params = { ids: [] }
      if (batch) {
        const multipleSelection = this.multipleSelection
        if (multipleSelection.length === 0) {
          return this.$message.warning('请选择数据！')
        } else {
          multipleSelection.forEach(item => {
            params.ids.push(item.orderNo)
          })
        }
      } else {
        params.ids.push(obj.orderNo)
      }
      this.$confirm('是否备货已选中的订单?', '备货', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$api.logisticsDoArrange(params).then((res) => {
          if (res.code === 0) {
            this.fetchData()
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
          } else {
            console.log('失败')
          }
        }).catch((err) => {
          console.log(err)
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    onChangeLogisticsStatus (status) {
		console.log(status)
      // this.form = Object.assign({}, {})
      const columnCommon = this.columnCommon
      const columnMiddle = this.columnMiddle
      this.currentStatus = status
      this.page.status = status
      if (status === '') {
        this.page.status = ''
      }
      this.multipleSelection = [] // 切换列表时清空已选项
      this.columns = []
      // 全部
      if (this.currentStatus === this.logisticsStatus.all.values) {
        this.columns = columnCommon.concat(this.columnAll)
      }
      // 待备货
      if (this.currentStatus === this.logisticsStatus.stayStockUp.values) {
        this.columns = columnCommon.concat(columnMiddle)
        this.setListOperation()
      }
      // 已备货
      if (this.currentStatus === this.logisticsStatus.stockUp.values) {
        this.columns = columnCommon.concat(columnMiddle)
        this.setListOperation()
      }
      // 待发货
      if (this.currentStatus === this.logisticsStatus.stayDeliverGoods.values) {
        this.columns = columnCommon.concat(columnMiddle)
        this.setListOperation()
      }
      // 已发货
      if (this.currentStatus === this.logisticsStatus.deliverGoods.values) {
        const colStatus = {
          label: '物流状态', minWidth: '100',
          render: (h, scope) => {
            return (
                <div>
                  <p>{scope.row.logisticsExceptionStatus ? '异常' : '正常'}</p>
                </div>
            )
          }
        }
        this.columns = columnCommon.concat(columnMiddle)
        this.columns.splice(11, 0, colStatus)

        this.setListOperation()
      }
      // 售后件
      if (this.currentStatus === this.logisticsStatus.afterSale.values) {
        this.columns = [...columnCommon, ...this.columnAfterSale]
        this.searchFormConfig.formconfig.itemList = this.itemListAll
        this.setSearchDictionaries('售后状态', 'after_sale_status')
        this.setSearchDictionaries('售后原因', 'after_sale_reason')
      } else {
        this.searchFormConfig.formconfig.itemList = this.itemListSplice
      }
      this.page.pageNo = 1
      this.page.pageSize = 10
      this.page.currentPage = 1
      this.fetchData('status')
    },
    setListOperation (type, jurisdiction) {
      // 权限 显示
      // const jurisdiction = "<el-link type='primary' size='mini' type='primary'>jurisdiction</el-link>"
      const currentStatus = this.currentStatus
      const operation = {
        label: '操作',
        width: '230',
        fixed: 'right',
        render: (h, scope) => {
          switch (currentStatus) {
            case 1: // 待备货
              // console.log('待备货')
              return (
                  <div>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.toOtherPages('orderDetails', scope.row, 'logistics')
                    }}>查看
                    </el-link>
                    <el-link type='primary' type='danger' onClick={() => { this.showDialog('关闭订单', '640px', 'closeOrder', scope.row, scope.$index) }}>关闭订单</el-link>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.onStockUp(false, scope.row)
                    }}>备货
                    </el-link>
                    <el-link type='primary' size='mini' onClick={() => { this.showDialog('审核流程', '640px', 'shenheStep', scope.row, scope.$index) }}>进度</el-link>

                  </div>
              )
              break
            case 2: // 已备货
              // console.log('已备货')
              return (
                  <div>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.toOtherPages('orderDetails', scope.row, 'logistics')
                    }}>查看
                    </el-link>

                    <el-link type='primary' type='danger' onClick={() => { this.showDialog('关闭订单', '640px', 'closeOrder', scope.row, scope.$index) }}>关闭订单</el-link>
                    <el-link type='primary' size='mini' onClick={() => { this.showDialog('审核流程', '640px', 'shenheStep', scope.row, scope.$index) }}>进度</el-link>

                  </div>
              )
              break
            case 3: // 待发货
              // console.log('待发货')
              return (
                  <div>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.toOtherPages('orderDetails', scope.row, 'logistics')
                    }}>查看
                    </el-link>

                    <el-link type='primary' size='mini' onClick={() => {
                      this.showDialog('发货', '500px', 'modifyOrderNoOne', scope.row, scope.$index)
                    }}>发货
                    </el-link>
                    <el-link type='primary' type='danger' onClick={() => { this.showDialog('关闭订单', '640px', 'closeOrder', scope.row, scope.$index) }}>关闭订单</el-link>
                    <el-link type='primary' size='mini' onClick={() => { this.showDialog('审核流程', '640px', 'shenheStep', scope.row, scope.$index) }}>进度</el-link>

                  </div>
              )
              break
            default: // 已发货
              // console.log('已发货')
              return (
                  <div>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.toOtherPages('orderDetails', scope.row, 'logistics')
                    }}>查看
                    </el-link>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.showDialog('修改物流单号', '500px', 'modifyOrderNoOne', scope.row, scope.$index)
                    }}>修改物流单号
                    </el-link>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.showDialog('物流信息', '640px', 'logisticsMessageOne', scope.row, scope.$index)
                    }}>物流信息
                    </el-link>
                    <el-link type='primary' size='mini' onClick={() => {
                      this.wuliuAbnormal(scope.row)
                    }}>物流异常
                    </el-link>
                    <el-link type='primary' size='mini' onClick={() => { this.showDialog('审核流程', '640px', 'shenheStep', scope.row, scope.$index) }}>进度</el-link>

                  </div>
              )
          }
        }
      }
      this.columns.push(operation)
      // console.log(this.columns[this.columns.length - 1])
    },
    // 导出记录列表查询
    onApplierExport () {
      this.dialog.visible = true
      this.dialog.title = '导出记录'
      this.dialog.width = '745px'
      this.dialog.type = 'deriveRecord'

      const params = {
        pageNo: this.page.pageNo,
        pageSize: this.page.pageSize,
        status: 2
      }
      /*
      params = Object.assign(params, this.searchForm)
      params.orgCode = params.orgCode[params.orgCode.length - 1]
      */

      // const searchForm = this.searchFormVal
      // // params = Object.assign(params, searchForm)
      // if (params.postTime) {
      //   params.postTimeStart = params.postTime[0]
      //   params.postTimeEnd = params.postTime[1]
      // }
      // if (params.createdTime) {
      //   params.createdTimeStart = params.createdTime[0]
      //   params.createdTimeEnd = params.createdTime[1]
      // }
      // // params.categoryId = searchForm.categoryId[searchForm.categoryId.length - 1]
      // // 去除字符串 前后 空格
      // for (const item in params) {
      //   if (typeof params[item] === 'string') {
      //     params[item] = params[item].trim()
      //   }
      // }

      this.$api.logisticsRecordsPage(params).then((res) => {
        if (res.code == 0) {
          this.deriveRecordList = res.data
        }
        // this.downloadlink(res.data)
      }).catch((err) => {
        console.log(err)
      })
    }
    // downloadlink (url) {
    //   const iframe = document.createElement('iframe')
    //   iframe.style.display = 'none'
    //   iframe.src = url
    //   document.body.appendChild(iframe)
    // }
  }
}
</script>

<style scoped lang="scss">
/deep/ .hide-content {
  display: none !important;
}

/deep/ .el-button {
  border: none;
}

/deep/ .el-link {
  margin: 0 5px
}

/deep/ .el-table th > .cell, /deep/ .el-table td {
  text-align: unset;
}

.but-list:after {
  clear: both;
  display: table;
  content: '';
}

.but-list {
  margin-bottom: 20px;

  .left {
    float: left;

    /deep/ .el-button {
      width: 120px;
      height: 36px;
      border-radius: 4px;
      font-size: 16px;
    }
  }

  .right {
    float: right;

    /deep/ .el-button {
      min-width: 120px;
      height: 36px;
      border-radius: 4px;
      font-size: 16px;
    }

    // 批量备货
    .stay-stock-up-but {
      color: #409EFF;
      border: 1px solid #409EFF;
      background-color: #ffffff;
    }

    // 导出发货
    .stock-up-send-but {

    }

    // 导出记录
    .stock-up-record-but {
      background-color: #7763DD;
    }

    // 导出物流单
    .stay-deliver-goods-but {

    }

    // 批量修改物流单号
    .deliver-goods-but {
      width: 160px;
      height: 36px;
      border: 1px solid #4168E7;
      border-radius: 4px;
      font-size: 16px;
      font-weight: 400;
      color: #4168E7;
    }
  }
}

.dialog-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;

  .cancel {
    width: 120px;
    height: 36px;
    border: 1px solid #D9D9D9;
    opacity: 1;
    border-radius: 4px;
  }

  .affirm {
    width: 120px;
    height: 36px;
    background: #4168E7;
    opacity: 1;
    border-radius: 4px;
  }
}

/deep/ .el-upload-dragger {
  width: 600px !important;
}

.dialogBtnright {
  display: flex;
  justify-content: space-between;
}

.dialogBtnright_right {
  display: flex;
  justify-content: right !important;

}

.setPay_payment_btn_quxiao {
  width: 120px;
  height: 36px;
  border: 1px solid #D9D9D9;
  background-color: #ffffff;
  color: rgba(153, 153, 153, 1);
  border-radius: 4px;
  line-height: 0;
}

.setPay_payment_btn_queren {
  width: 120px;
  height: 36px;
  background: #4168E7;
  opacity: 1;
  border-radius: 4px;
  line-height: 0;
  border: 0;
}

.block {
  text-align: right;
}

.setPay_payment {
  display: block;
  margin-bottom: 15px;
}

.dialog-btn {
  text-align: right;
}

/deep/ .el-table__row td .cell span, /deep/ .el-table__row td .cell div p {
  display: block;
  //overflow : hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* 可以显示的行数，超出部分用...表示*/
  -webkit-box-orient: vertical;
}

.wuliuAbnormal_box {
  display: flex;
  margin-bottom: 20px;
}

.radio_group {
  margin-left: 20px;
}

.radio_group_item {
  margin-bottom: 10px;
}

.wuliuAbnormal_box_title {
  margin-top: -5px;
}
/deep/.el-select{
  border-left: none;
  border-right: none;
  input{
    border-left: 1px solid #d8dce5!important;
    border-right: 1px solid #d8dce5!important;
    border-radius: 5px!important;
  }
}
/deep/.el-scrollbar{
  height:10px;
}
/deep/.el-scrollbar__bar.is-horizontal{
  height: 9px;

}

</style>
